<template>
	<div id="finance_flow">
    <el-form :inline="true" class="demo-form-inline" size="medium" :disabled="load">
      <el-form-item>
        <el-select v-model="requestParam.type" placeholder="支付类型" @change="search">
          <el-option value="" label="全部"></el-option>
          <el-option value="1" label="收入"></el-option>
          <el-option value="2" label="支出"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="list" stripe style="width: 100%" v-loading="load">
      <el-table-column prop="id" label="id" align="center"></el-table-column>
      <el-table-column label="金额" width="120" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.type == 1">{{scope.row.money>0?'+':''}}{{$common.toThousands(scope.row.money, true)}}</span>
          <span v-if="scope.row.type == 2" class="error">- {{$common.toThousands(scope.row.money, true)}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="deal_desc" label="交易描述"  align="center"></el-table-column>
      <el-table-column prop="remark" label="备注"  align="center"></el-table-column>
      <el-table-column prop="status" label="状态"  align="center">
      </el-table-column>
      <el-table-column  label="创建时间" align="center">
        <template slot-scope="scope">
          <span>{{$moment(scope.row.createTime).format('Y-MM-DD HH:mm')}}</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="page"
      background
      layout="total, prev, pager, next"
      :page-size="requestParam.pageSize"
      :total="total"
      @current-change="getList"
    >
    </el-pagination>
	</div>
</template>

<script>
	export default {
		data() {
			return {
        list: [],
        requestParam:{
          usId: '',
          startTime: '',
          endTime: '',
          pageSize: 10,
          isCount: false,
          type: '',
          tenantid:sessionStorage.getItem("tenantid")
        },
        total: 0,
        load: false,
        date: [],
			};
		},

    mounted(){
      this.search(1)
    },

    methods:{
      // 获取列表
      getList(pageNo){
        if(this.load){
          return;
        }
        if(this.date && this.date.length){
          this.requestParam.startTime = this.$moment(this.date[0]).format('Y-MM-DD HH:mm:ss')
          this.requestParam.endTime = this.$moment(this.date[1]).format('Y-MM-DD HH:mm:ss')
        }else{
          this.date = [];
          this.requestParam.startTime = ''
          this.requestParam.endTime = ''
        }
        this.load = true
        this.requestParam.pageNo = pageNo
        this.$request.post({
          url: '/ReportApi/tenant/financeunflowlist',
          params: this.requestParam,
          success: result=>{
            this.list = result[0]
            if(this.requestParam.isCount){
              this.total = result[1]
              this.requestParam.isCount = false
            }
          },
          finally: ()=>{
            this.load = false
          }
        })
      },

      search(){
        this.requestParam.isCount = true;
        this.getList(1)
      }
		}

	}
</script>

<style>

</style>

<style scoped>
	.page{
		text-align: right;
		margin-top: 20px;
	}
</style>
